<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="${staticResources}/css/jquery-ui-1.8.17.custom.css" rel="stylesheet" />
<script src="${staticResources}/jquery/jquery-1.5.1.js"></script>
<script src="${staticResources}/jquery/jquery-ui-1.8.17.custom.min.js"></script>
<script src="${staticResources}/jquery/jquery-ui-widget-combobox.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="${staticResources}/js/ajax.js"></script>
<title>发布书籍</title>
<link type="text/css" href="${staticResources}/css/publishbook.css" rel="stylesheet" />
<style type ="text/css">
.xuanfu{
position:absolute;
width:390px;
border-left:1px solid #000;
border-right:1px solid #000;
background: url('${staticResources}/image/searchdivbg.jpg') no-repeat;
}
.searchchangewhite
{
background:#FFFFFF;
cursor:hand;}
.searchchangegray
{cursor:hand;
}

</style>
<script type="text/javascript">
function hahacheck()
{
	var name = document.getElementById("content").value;
	var chiefeditor = document.getElementById("chief").value;
	var description = document.getElementById("description").value;
	var version = document.getElementById("version").value;
	var publisher = document.getElementById("publisher").value;
	var price = document.getElementById("price").value;
	var category = document.getElementById("category").value;
	var condition = document.getElementById("condition").value;
	var hasnote = document.getElementById("hasnote").value;
	if(name =="" ||chiefeditor ==""||description ==""||version ==""
			||publisher ==""||price ==""||category ==""||condition ==""
			||name == null ||chiefeditor ==null||description ==null||version ==null
				||publisher ==null||price ==null||category ==null||condition ==null)
		{
		//document.getElementById("publishresult").value = "数据信息填写不完全哦";
		alert("数据信息填写不完全哦");
		return;
		}

	var param = "name="+encodeURIComponent(name);
	param += "&chiefeditor="+encodeURIComponent(chiefeditor);
	param += "&description="+encodeURIComponent(description);
	param += "&publisher="+encodeURIComponent(publisher);
	param += "&price="+encodeURIComponent(price);
	param += "&version="+encodeURIComponent(version);
	param += "&category="+encodeURIComponent(category);
	param += "&condition="+encodeURIComponent(condition);
	param += "&hasnote="+encodeURIComponent(hasnote);
	param += "&mode="+"ajax";
	
	doAjax("PublishBook",param,function(rst){
		
		var rs = eval('(' +rst+ ')');
		if(rs.status == 1)
			{
			//document.getElementById("description").value = "您还没有登录呢";

			alert("您还没有登录呢");
			}
		if(rs.status == 3)
		{
		//document.getElementById("description").value = "尚未填写分类";
		alert("尚未填写分类");
		}
		if(rs.status == 4)
		{
		//document.getElementById("description").value = "分类格式错误";
		alert("分类格式错误");
		}
		if(rs.status == 5)
		{
		//document.getElementById("description").value = "尚未填写价格";
		alert("尚未填写价格");
		}
	
		if(rs.status == 6)
		{
		//document.getElementById("description").value = "价格格式错误，哪有你这么定义价格的，这不是调戏我嘛";
		alert("价格格式错误，哪有你这么定义价格的，这不是调戏我嘛");
		}
		if(rs.status == 7)
		{
		//document.getElementById("description").value = "尚未填写笔记情况";
		alert("尚未填写笔记情况");
		}
		if(rs.status == 8)
		{
		//document.getElementById("description").value = "笔记格式错误";
		alert("笔记格式错误");
		}
		if(rs.status == 10)
		{
		//document.getElementById("description").value = "不好意思，发布失败了";
		alert("不好意思，发布失败了");
		}
		if(rs.status == 11)
		{
		//document.getElementById("description").value = "恭喜您，发布成功，情去添加图片后等待上架吧";
			window.location.href="UploadPicture?beid="+rs.beid; 
		}
		if(rs.status == 12)
		{
		//document.getElementById("description").value = "恭喜您，发布成功，情去添加图片后等待上架吧";
		alert("您还没有填写新旧程度");
		}
		if(rs.status == 13)
		{
		//document.getElementById("description").value = "恭喜您，发布成功，情去添加图片后等待上架吧";
		alert("新旧程度格式错误");
		}
		
		
		
		
	});
	}
</script>
<script type ="text/javascript">
//取得搜索下拉框
var rst0;
document.rst = null;
function getbooklist()
{
	
	var content = document.getElementById("content").value;
	var mode = "ajax";
	var param = "keyword="+encodeURIComponent(content);
	param +="&mode="+encodeURIComponent(mode);
	param +="&pageSize=10";
	var div = document.getElementById("booklist");
	

	var str = "";
	doAjax("Search" , param , function(rst){
		var result = eval('('+rst+')');
		document.rst = result;
		if(result.length == 0 )
			{
			str = "尚未收录此书";
			div.innerHTML =str;	
			return;
			}
		for(var i = 0;i<result.length;i++)
			{
			/*
			str +="<div style = \"border:1px solid #000;\"onmouseover=\"this.className='searchchangewhite'\" onmouseout=\"this.className='searchchangegray'\"><div onclick=\"";
			
			str +="value('"+result[i].name.replace("'","\\'")+"'";
			str +=",'"+result[i].publisher+"'";
			str +=",'"+result[i].version+"'";
			str +=",'"+result[i].chiefEditor+"'";
			str += ");";
			
			str +="\"><b>"+result[i].name+"</b></div>";
			*/
			
			/*str +="<div style = \"border:1px solid #000;\"onmouseover=\"this.className='searchchangewhite'\" onmouseout=\"this.className='searchchangegray'\"><a href=\"#\" onclick=\"";
			
			str +="value('h','3','3','2');+";
			
			str +="value('"+result[i].name.replace("'","\\'")+"'";
			str +=",'"+result[i].publisher+"'";
			str +=",'"+result[i].version+"'";
			str +=",'"+result[i].chiefEditor+"'";
			str += ");";
			
			str += "return false;";
			
			str +="\"><b>"+result[i].name+"</b></a>";
			
				
			str +="<div style= \"font-size:10px;margin:-10px 0px 0px 0px;\">"+"出版社"+result[i].publisher+"   版本："+result[i].version+"</div></div>";*/
			str +="<div onmouseover=\"this.className='searchchangewhite'\" onmouseout=\"this.className='searchchangegray'\"><a href = \"#\"  onclick=\"value('"
				+i+"','"+
				+i+"','"+
				+i+"','"+
				+i+"');return false;\"><b>"+result[i].name+"</b></a>";
			str +="<div style= \"font-size:10px;margin:-10px 0px 0px 0px;\">"+"出版社"+result[i].publisher+"   版本："+result[i].version+"</div></div>";


			}
		str +="<div style=\"border:1px dotted #021;border-bottom:1px solid #000;background:#FFFFFF;\"><a href=\"#\" onclick=\"hidediv();\">点击隐藏智能输入框</a></div>";
		div.innerHTML =str;		
	} );
	}
	function hidediv()
	{
		var div = document.getElementById("booklist");
		div.innerHTML="";
	}
	function value(n,p,v,c)
	{
		var i = n;
		var a = document.getElementById("content").value = document.rst[i].name;
			a = document.getElementById("publisher").value =document.rst[i].publisher;
			a = document.getElementById("version").value = document.rst[i].version;
			a = document.getElementById("chief").value = document.rst[i].chiefEditor;
			a = document.getElementById("category").value = document.rst[i].category.CID;
		var a =document.getElementById("booklist").innerHTML="";
		
	}
//取得发布书籍服务器的JSOn

 </script>
<script type="text/javascript" src="${staticResources}/js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="${staticResources}/js/jquery-ui.js"></script>

</head>
<body style=" background: url('${staticResources}/image/greenbc.gif');">
<div id="header">
  <div id="hy">
    <c:if test="${user eq null }">
    <div id="logo">欢迎光临中国药科大学二手书交易平台!请<span><a href="${contextPath }/Account/Login">登录</a></span> 免费<span><a href="${contextPath }/Account/Register">注册</a></span></div>
    </c:if>
    <c:if test="${user ne null }">
    <div id="sc">
      <ul>
        <li><a href="${contextPath }/Account/Logout">注销</a></li>
        <li><a href="${contextPath }/Me?content=201">收藏夹</a></li>
        <li><a href="${contextPath }/Me">个人中心</a></li>
        <li>欢迎你，<b>${fn:escapeXml(user.nickName) }</b>！</li>
      </ul>
    </div>
    </c:if>
  </div>
  <div id="top" style=" background: url('${staticResources}/image/listcommentsbc_03.gif');">
      <div class="tx">
	    <dl>
	     <c:choose>
           <c:when test="${empty user.userPicture }">
             <img src="${staticResources}/image/userpics_none.jpg" width="132" height="132" alt="">
           </c:when>
           <c:otherwise>
             <img src="${userContents}/userpics/${user.userPicture }" width="132" height="132" alt="">
           </c:otherwise>
	     </c:choose>
	    </dl>
	  </div>
	  <div class="xx">
	     <dl class="nc">${fn:escapeXml(user.nickName)}</dl>
		 <dl class="degree">活跃度：${user.activityPoint}</dl>
		 <dl class="degree">信誉度：${user.creditPoint}</dl>
		 <dl class="degree">个性签名：${fn:escapeXml(user.signature)}</dl>
	  </div>
   </div>
 </div>
 
		 			
   <div id="nav" style=" background: url('${staticResources}/image/listcomments_07.gif');">
    <ul>
      <li><a href="${contextPath }/Homepage">首页</a></li>
      <li><a href="${contextPath }/Books/Search">交易广场</a></li>
      <li><a href="${contextPath }/Auctions/Search">拍卖中心</a></li>
      <li><a href="#">读者推荐</a></li>
      <li><a href="${contextPath }/Comment/ListComments">留言板</a></li>
      <li><a href="#">新手指南</a></li>
    </ul>
   </div>
<!--头部结束-->

<div class="main"  style=" background: url('${staticResources}/image/viewcomment_background2.jpg');">

  <form method="post" name="" action="" style="width:600px;" id="fancyform">
	          <div class="con">

			       <dl>
				       <dd>书名：</dd>
				       <div>
			           <input type="text" id="content" onkeyup="getbooklist();" style="width:400px; height:25px; margin::20px 0px 20px 5px;" name=""/>
			           <div id ="booklist" class="xuanfu" style="margin:0px 0px 0px 90px;width:404px;">
			       
			           </div></div>
				   </dl>
				   <div class="clear"></div>			       
				   <dl>
				       <label><dd>版本：</dd></label>
			           <input id = "version"type="text" id="" style="width:400px; height:25px; margin::20px 0px 20px 5px;"name=""/>

				   </dl>
				   <div class="clear"></div>
				   <dl>

				       <dd>出版社：</dd>
			           <input id ="publisher"type="text" id="" style="width:400px; height:25px; margin::20px 0px 20px 5px;"name=""/>

				     
				   </dl>
				   <div class="clear"></div>
				   <dl>

				       <label><dd>主编：</dd></label>
			           <input id = "chief" type="text" id="" style="width:400px; height:25px; margin::20px 0px 20px 5px;"name=""/>

				   </dl>
				   <div class="clear"></div>
				   <dl>
				       <label><dd>分类：</dd></label>
					   <select id="category" name="" size="" style="width:400px; height:25px; margin:0px 0px 0px 0px; font-size:18px;">
					       <option value="" selected="selected">分类</option>
						   <option value="1" >化学</option>
						   <option value="2" >物理</option>
						   <option value="3" >生物</option>
						   <option value="4" >英语</option>
						   <option value="5" >数学</option>
						   <option value="6" >语文</option>
						   <option value="7" >历史</option>
						   <option value="8" >地理</option>
						   <option value="9" >政治</option>
						   <option value="10" >计算机</option>
						   <option value="11" >音乐</option>
						   <option value="12" >美术</option>
						   <option value="13" >体育</option>
						   <option value="14" >管理</option>
						   </select>
			           
				   </dl>
				   <div class="clear"></div>
				   <dl>
				       <label><dd>价格：</dd></label>
			           <input  type="text" id="price" style="width:400px; height:25px; margin::20px 0px 20px 5px;"name=""/>
				   </dl>
				   <div class="clear"></div>
				   <dl>
				       <label><dd>新旧程度：</dd></label>
			           <select id = "condition" name="" size="" style="width:400px; height:25px; margin:0px 0px 0px 0px; font-size:18px;">
					       <option value="" selected="selected">新旧程度</option>
						   <option value="1" >一成新</option>
						   <option value="2" >二成新</option>
						   <option value="3" >三成新</option>
						   <option value="4" >四成新</option>
						   <option value="5" >五成新</option>
						   <option value="6" >六成新</option>
						   <option value="7" >七成新</option>
						   <option value="8" >八成新</option>
						   <option value="9" >九成新</option>
						   <option value="10" >十成新</option>
					   </select>
				   </dl>
				   <div class="clear"></div>
				   <dl>
				       <label><dd>笔记情况：</dd></label>
			           <select id = "hasnote" name="" size="" style="width:400px; height:25px; margin:0px 0px 0px 0px; font-size:18px;">
					       <option value="" selected="selected">笔记情况</option>
						   <option value="1" >无笔记</option>
						   <option value="2" >较少笔记</option>
						   <option value="3" >较多笔记</option>
						   <option value="4" >详细笔记</option>
					   </select>
				   </dl>
				   <div class="clear"></div>
				   <dl>
				       <label><dd>卖家描述：</dd></label>
				       <textarea id="description" style="width:400px; height:100px; margin:20px 0px 20px 5px;" ></textarea>
			           <!-- <input type="text" id="description" style="width:400px; height:100px; margin::20px 0px 20px 5px;"name=""/> -->
				   </dl>
				   
			  </div>
		      <div class="botton"><input type="image" style=""src="${staticResources}/image/submitcomment_03.gif" onclick ="hahacheck();return false;" width="100" height="35" alt="" class="button" name="commit" value=""/>
			  </div>
		 </form>
		 
  
</div>
<!--中间部分结束-->

     <div class="bottom">中国药科大学版权所有</div>

<!--尾部结束-->


</body>
</html>
